package ru.stool.erp.model.utils;

import java.security.MessageDigest;

public class PasswordUtils {

	private PasswordUtils(){
		
	}
	
	public static String getPasswordHash(String password){
		String passwordHash=null;
		
		try{
			MessageDigest md=MessageDigest.getInstance("SHA-256");
		
			md.update(password.getBytes("UTF-8"));
		
			byte[] hash=md.digest();
		
			passwordHash=new String(hash);
		}catch(Exception ex){
			throw new RuntimeException("Cannot get password SHA-256 hash.", ex);
		}
		
		return passwordHash;
	}
	
}
